Definition:
- Developers introduce this smell when they need to pause execution of statements in a test method for a certain duration (i.e., simulate an external event) and then continuing with execution. Explicitly causing a thread to sleep can lead to unexpected results as the processing time for a task differs when executed in various environments and configurations.
Code Example:
public void testEdictExternSearch() throws Exception {
final Intent i = new Intent(getInstrumentation().getContext(), ResultActivity.class);
i.setAction(ResultActivity.EDICT_ACTION_INTERCEPT);
i.putExtra(ResultActivity.EDICT_INTENTKEY_KANJIS, "空白");
tester.startActivity(i);
assertTrue(tester.getText(R.id.textSelectedDictionary).contains("Default"));
final ListView lv = getActivity().getListView();
assertEquals(1, lv.getCount());
DictEntry entry = (DictEntry) lv.getItemAtPosition(0);
assertEquals("Searching", entry.english);
Thread.sleep(500);
final Intent i2 = getStartedActivityIntent();
final List result = (List) i2.getSerializableExtra(ResultActivity.INTENTKEY_RESULT_LIST);
entry = result.get(0);
assertEquals("(adj-na,n,adj-no) blank space/vacuum/space/null (NUL)/(P)", entry.english);
assertEquals("空白", entry.getJapanese());
assertEquals("くうはく", entry.reading);
assertEquals(1, result.size());
}
References:
Quality attributes
- :octicon:`file-code;1em` - Code Example
- :octicon:`comment-discussion;1em` - Cause and Effect
- :octicon:`graph;1em` - Frequency
- :octicon:`sync;1em` - Refactoring
- An Exploratory Study on the Refactoring of Unit Test Files in Android Applications :octicon:`comment-discussion;1em` :octicon:`sync;1em`
- Automatic Identification of High-Impact Bug Report by Product and Test Code Quality
- Automatic generation of smell-free unit tests :octicon:`comment-discussion;1em`
- Characterizing High-Quality Test Methods: A First Empirical Study :octicon:`graph;1em`
- Handling Test Smells in Python: Results from a Mixed-Method Study
- Investigating Severity Thresholds for Test Smells :octicon:`comment-discussion;1em`
- Investigating Test Smells in JavaScript Test Code :octicon:`graph;1em`
- On the Distribution of "Simple Stupid Bugs" in Unit Test Files: An Exploratory Study
- On the diffusion of test smells and their relationship with test code quality of Java projects :octicon:`graph;1em`
- On the distribution of test smells in open source Android applications: an exploratory study :octicon:`file-code;1em` :octicon:`graph;1em`
- On the influence of Test Smells on Test Coverage
- On the test smells detection: an empirical study on the jnose test accuracy :octicon:`graph;1em`
- On the use of test smells for prediction of flaky tests :octicon:`comment-discussion;1em` :octicon:`graph;1em`
- PyNose: A Test Smell Detector For Python :octicon:`comment-discussion;1em` :octicon:`graph;1em`
- Pytest-Smell: a smell detection tool for Python unit tests :octicon:`graph;1em`
- Software Unit Test Smells :octicon:`file-code;1em`
- TEMPY: Test Smell Detector for Python :octicon:`graph;1em`
- Test Smell Detection Tools: A Systematic Mapping Study
- The secret life of test smells-an empirical study on test smell evolution and maintenance :octicon:`graph;1em`
- Understanding practitioners’ strategies to handle test smells: a multi-method study :octicon:`comment-discussion;1em` :octicon:`sync;1em`
- What the Smell? An Empirical Investigation on the Distribution and Severity of Test Smells in Open Source Android Applications :octicon:`file-code;1em` :octicon:`graph;1em`
- tsDetect: an open source test smells detection tool